package com.biz.primus.ms.member.dao.repository;

import com.biz.primus.model.member.enums.AddressTypes;
import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import com.biz.primus.ms.member.dao.po.MemberAddress;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 *
 * @author jun.liu
 * @usage
 * @reviewer
 * @since 2017-10-23
 */
public interface MemberAddressRepository extends CommonJpaRepository<MemberAddress, Long>, MemberAddressDao
{
    List<MemberAddress> findByMemberrAddressLabelId(Long memberrAddressLabelId);

    List<MemberAddress> findByMemberIdAndAddressType(Long memberId, AddressTypes addressType);

    List<MemberAddress> findByMemberId(Long memberId);

    @Query("from MemberAddress r where r.memberId =?1 and r.defaultAddress = true ")
    List<MemberAddress> listByUserIdDefaultAddress(Long memberId);
}
